﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //string newDir = @"D:\Inteducation\Valer_Malin\20.12.2016 classwork\Dir";
            //Directory.CreateDirectory(newDir);

            //string[] files = Directory.GetFiles(@"D:\Inteducation\Valer_Malin\20.12.2016 classwork\ConsoleApplication1", "*.txt", SearchOption.TopDirectoryOnly);
            //for (int i=0; i<files.Length;i++)
            //{
            //    Console.WriteLine(files[i]);
            //}

            //if (Directory.Exists(newDir))
            //{
            //    foreach (var file in files)
            //    {
            //        string file2 = file.Replace("ConsoleApplication1", "Dir");
            //        File.Copy(file, file2);
            //    }
            //}
            //bool isDirectoryExist = Directory.Exists(@"D:\Inteducation\Valer_Malin\20.12.2016 classwork\Dir");
            //        if (isDirectoryExist)
            //        {
            //            Directory.Delete(@"D:\Inteducation\Valer_Malin\20.12.2016 classwork\Dir", true);
            //        }

            //string text = "Вставка";
            //string[] files2= Directory.GetFiles(newDir, "*.txt", SearchOption.TopDirectoryOnly);
            //foreach(var file in files2)
            //{
            //    File.WriteAllText(file, text);
            //}

            string str = File.ReadAllText(@"C:\Users\Valer_Malin\Downloads\HT.txt");
            string[] textFromFile = str.Split( );
            int counter = 0;
            int longestWordNumber=0;
            int longestSymbolQuantity = 1;
            for (int i = 0; i < textFromFile.Length; i++)
            {
                if (textFromFile[i].IndexOf("(")!=-1) textFromFile[i] = textFromFile[i].Substring(textFromFile[i].IndexOf("(")+1);
                if (textFromFile[i].IndexOf(")") != -1) textFromFile[i] = textFromFile[i].Substring(0,textFromFile[i].IndexOf(")"));
                if (textFromFile[i].IndexOf(".") != -1) textFromFile[i] = textFromFile[i].Substring(0, textFromFile[i].IndexOf("."));
                if (textFromFile[i].IndexOf(",") != -1) textFromFile[i] = textFromFile[i].Substring(0, textFromFile[i].IndexOf(","));
                if (textFromFile[i].Length > longestSymbolQuantity)
                {
                    longestSymbolQuantity = textFromFile[i].Length;
                    longestWordNumber = i;
                }

                if (textFromFile[i] != "") counter++;
            }
            Console.WriteLine("слов в файле {0}", counter);
            Console.WriteLine("самое длинное слово {0}", textFromFile[longestWordNumber]);



        }
    }
}
